package www.openteam.com.presenter.business.other;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.PbProductInfo;
import www.openteam.com.contract.business.other.SearchPackTypeInfoContract;
import www.openteam.com.contract.business.other.SearchPbContract;
import www.openteam.com.model.business.other.SearchPbProductInfoModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.business.other.SearchFragment;

/**
 * Created by kylin on 2016/11/25.
 */

public class SearchPbProductInfoPresenter extends BasePresenter<SearchFragment>
        implements SearchPbContract.SearchPbProductInfoPresenter {
    public void queryPbproductInfo(String name, int pageSize) {
        ((SearchPbProductInfoModel) getiModelMap().get("searchPb"))
                .queryPbproductInfo(name, pageSize, new SearchPbProductInfoModel.SearchPbProductInfoOnListener() {
                    @Override
                    public void queryPPISuccess(PbProductInfo pbProductInfo) {

                        getIView().loadPPIData(pbProductInfo);
                    }

                    @Override
                    public void queryPPIFail(Throwable throwable) {
                        getIView().hidePPIData(throwable);
                    }
                });

    }

    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new SearchPbProductInfoModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("searchPb", models[0]);


        return hashMap;
    }
}
